Skip to content

Commit

Permalink
Add clang-format conf.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeolar committed Jul 28, 2017
1 parent 75e6959 commit b1507a0
Show file tree
Hide file tree
Showing 194 changed files with 386 additions and 491 deletions.
11 changes: 11 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html

BasedOnStyle: Google
IndentWidth: 2
UseTab: Never
AccessModifierOffset: -2
IndentCaseLabels: false
AllowShortBlocksOnASingleLine: false
#AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
2 changes: 1 addition & 1 deletion rddoc/concurrency/CPUThreadPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ size_t CPUThreadPool::getPendingTaskCount() {
return taskQueue_.size();
}

}
} // namespace rdd
2 changes: 1 addition & 1 deletion rddoc/concurrency/CPUThreadPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ class CPUThreadPool : public ThreadPool {
std::atomic<ssize_t> threadsToStop_{0};
};

}
} // namespace rdd
2 changes: 1 addition & 1 deletion rddoc/concurrency/IOThreadPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ size_t IOThreadPool::getPendingTaskCount() {
return count;
}

}
} // namespace rdd
2 changes: 1 addition & 1 deletion rddoc/concurrency/IOThreadPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ class IOThreadPool : public ThreadPool {
EventLoopManager* eventLoopManager_;
};

}
} // namespace rdd
2 changes: 1 addition & 1 deletion rddoc/concurrency/Observable.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,4 @@ struct Subject : public Observable<T>, public Observer<T> {
template <class T> using ObservablePtr = std::shared_ptr<Observable<T>>;
template <class T> using SubjectPtr = std::shared_ptr<Subject<T>>;

}
} // namespace rdd
2 changes: 1 addition & 1 deletion rddoc/concurrency/Observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ struct FunctionObserver : public Observer<T> {

template <class T> using ObserverPtr = std::shared_ptr<Observer<T>>;

}
} // namespace rdd
2 changes: 1 addition & 1 deletion rddoc/concurrency/ThreadFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ class ThreadFactory {
std::atomic<uint64_t> suffix_{0};
};

}
} // namespace rdd
2 changes: 1 addition & 1 deletion rddoc/concurrency/ThreadPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ void ThreadPool::runTask(const ThreadPtr& thread, Task&& task) {
thread->taskStatsSubject->on(std::move(task.stats_));
}

}
} // namespace rdd
2 changes: 1 addition & 1 deletion rddoc/concurrency/ThreadPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,4 @@ class ThreadPool {
std::vector<std::shared_ptr<Observer>> observers_;
};

}
} // namespace rdd
2 changes: 1 addition & 1 deletion rddoc/coroutine/BoostContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ class Context {
MainContext mainContext_;
};

}
} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/coroutine/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,4 @@ class Context {
ucontext_t mainContext_;
};

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/coroutine/Executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,4 @@ class Executor {

typedef std::shared_ptr<Executor> ExecutorPtr;

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/coroutine/Fiber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ namespace rdd {

std::atomic<size_t> Fiber::count_(0);

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/coroutine/Fiber.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,4 @@ class Fiber : noncopyable {
std::vector<Timestamp> timestamps_;
};

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/coroutine/FiberManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ namespace rdd {

__thread Fiber* FiberManager::fiber_ = nullptr;

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/coroutine/FiberManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,4 @@ inline ExecutorPtr getCurrentExecutor() {
return fiber ? fiber->executor() : nullptr;
}

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/coroutine/GenericExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ class FunctionExecutor : public GenericExecutor {
VoidFunc func_;
};

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/enc/CharProperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,4 @@ bool CharProperty::compile(const std::string& cfile,
return true;
}

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/enc/CharProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,4 @@ class PeckerCharProperty : public CharProperty {
CharInfo alnum_; // 数字或英文字母
};

}

} // namespace rdd
5 changes: 2 additions & 3 deletions rddoc/enc/uconv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,5 @@ bool is_gbk_n(const char *src, int length) {
return true;
}

}
}

} // namespace uconv
} // namespace rdd
5 changes: 2 additions & 3 deletions rddoc/enc/uconv.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,5 @@ int is_utf8(const char *str, unsigned int len, bool check_last_char);
bool is_gbk(const char *src);
bool is_gbk_n(const char *src, int length);

}
}

} // namespace uconv
} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/framework/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,4 @@ void config(const char* name, std::initializer_list<ConfigTask> confs) {
}
}

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/framework/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ void configJobGraph(const dynamic& j);

void config(const char* name, std::initializer_list<ConfigTask> confs);

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/io/Descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ class Descriptor {
virtual std::string str() = 0;
};

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/io/FSUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ inline path canonical_parent(const path& p,
return canonical(p.parent_path(), base) / p.filename();
}

}

} // namespace fs
2 changes: 1 addition & 1 deletion rddoc/io/File.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ class File : private noncopyable {

inline void swap(File& a, File& b) { a.swap(b); }

}
} // namespace rdd
4 changes: 2 additions & 2 deletions rddoc/io/FileUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ ssize_t wrapFull(F f, int fd, void* buf, size_t count, Offset... offset) {
return totalBytes;
}

}
} // namespace detail

inline int openNoInt(const char* name, int flags, mode_t mode = 0666) {
return int(detail::wrapNoInt(open, name, flags, mode));
Expand Down Expand Up @@ -161,4 +161,4 @@ bool writeFile(const Container& data, const char* filename,
return closeNoInt(fd) == 0 && ok;
}

}
} // namespace rdd
2 changes: 1 addition & 1 deletion rddoc/io/HugePageUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void list() {
}
}

}
} // namespace

int main(int argc, char *argv[]) {
std::string usage =
Expand Down
4 changes: 2 additions & 2 deletions rddoc/io/HugePages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ HugePageSizeVec readHugePageSizes() {
return sizeVec;
}

} // namespace
} // namespace

const HugePageSizeVec& getHugePageSizes() {
static HugePageSizeVec sizes = readHugePageSizes();
Expand Down Expand Up @@ -201,4 +201,4 @@ const HugePageSize* getHugePageSizeForDevice(dev_t device) {
return nullptr;
}

}
} // namespace rdd
2 changes: 1 addition & 1 deletion rddoc/io/HugePages.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ const HugePageSize* getHugePageSize(size_t size = 0);
*/
const HugePageSize* getHugePageSizeForDevice(dev_t device);

}
} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/io/TypedIOBuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,5 +194,4 @@ class TypedIOBuf {
IOBuf* buf_;
};

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/io/Waker.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,4 @@ class Waker : public Descriptor {
int pipeFds_[2];
};

}

} // namespace rdd
2 changes: 1 addition & 1 deletion rddoc/io/ZlibStreamCompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ std::unique_ptr<IOBuf> ZlibStreamCompressor::compress(const IOBuf* in,
return out;
}

}
} // namespace rdd
2 changes: 1 addition & 1 deletion rddoc/io/ZlibStreamCompressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ class ZlibStreamCompressor {
int status_{-1};
};

}
} // namespace rdd
2 changes: 1 addition & 1 deletion rddoc/io/ZlibStreamDecompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ std::unique_ptr<IOBuf> ZlibStreamDecompressor::decompress(const IOBuf* in) {
return out;
}

}
} // namespace rdd
2 changes: 1 addition & 1 deletion rddoc/io/ZlibStreamDecompressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ class ZlibStreamDecompressor {
int status_{-1};
};

}
} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/io/event/Event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,4 @@ int Event::writeData() {
return channel_->protocol()->writeData(this);
}

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/io/event/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,4 @@ class Event : private noncopyable {
ContextWrapper userCtx_;
};

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/io/event/EventExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ class EventExecutor : public GenericExecutor {
Event* event_;
};

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/io/event/EventHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,5 +233,4 @@ void EventHandler::closePeer(Event* event) {
}
}

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/io/event/EventHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ class EventHandler {
EventLoop* loop_;
};

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/io/event/EventLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,5 +203,4 @@ void EventLoop::checkTimeoutEvent() {
}
}

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/io/event/EventLoop.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,4 @@ class EventLoop {
TimedHeap<Event> deadlineHeap_;
};

}

} // namespace rdd
2 changes: 1 addition & 1 deletion rddoc/io/event/EventLoopManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ EventLoopManager* EventLoopManager::get() {

}

}
} // namespace rdd
2 changes: 1 addition & 1 deletion rddoc/io/event/EventLoopManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ class EventLoopManager : noncopyable {
std::mutex loopsLock_;
};

}
} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/io/event/EventPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,4 @@ size_t EventPool::count() const {
return n;
}

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/io/event/EventPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@ class EventPoolManager {
mutable std::mutex lock_;
};

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/io/event/Poll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,4 @@ void Poll::control(int op, int fd, uint32_t events, void* ptr) {
}
}

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/io/event/Poll.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,4 @@ class Poll {
epoll_event* events_;
};

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/net/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,4 @@ void Actor::monitoring() const {
*/
}

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/net/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,4 @@ class Actor {
std::vector<ForwardTarget> forwards_;
};

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/net/AsyncClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,4 @@ void AsyncClient::freeConnection() {
event_ = nullptr;
}

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/net/AsyncClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,4 @@ inline bool yieldMultiTask(std::initializer_list<AsyncClient*> clients) {
return false;
}

}

} // namespace rdd
3 changes: 1 addition & 2 deletions rddoc/net/AsyncClientExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ class AsyncClientExecutor : public GenericExecutor {
std::shared_ptr<AsyncClient> client_;
};

}

} // namespace rdd
Loading

0 comments on commit b1507a0

Please sign in to comment.