Skip to content

Instantly share code, notes, and snippets.

View ppLorins's full-sized avatar
🎯
Focusing

arthur ppLorins

🎯
Focusing
  • Tencent
  • ShenZhen,China
View GitHub Profile
#include <memory>
#include <iostream>
#include <string>
#include <thread>
#include <vector>
#include <list>
#include <random>
#include <atomic>
@ppLorins
ppLorins / proxy_adventurer.cc
Created October 21, 2019 08:12
grpc broadcasting pattern memory leak(c++)
#include <memory>
#include <iostream>
#include <string>
#include <thread>
#include <vector>
#include <list>
#include <random>
#include <atomic>
@ppLorins
ppLorins / greeter_async_client2.cc
Created July 19, 2019 09:37
an example for grpc async c++ client
/*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@ppLorins
ppLorins / greeter_proxy_server.cc
Created July 18, 2019 07:34
an example for the proxy async grpc c++ server forwarding requests for unary and bidi stream servers.
/*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@ppLorins
ppLorins / greeter_async_server.cc
Created July 18, 2019 07:23
an example for an unary async grpc c++ server.
/*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@ppLorins
ppLorins / bidi-server-cus.cc
Created July 18, 2019 07:22
an example for the bidirectional streaming async grpc c++ server.
/*
*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
@ppLorins
ppLorins / greeter_async_mixed_server.cc
Last active March 20, 2021 00:42
an example for writing an unary and bidi-stream mixed version of c++ async grpc server.
/*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@ppLorins
ppLorins / subclass_pointer_convert2_parentclass_pointer.cc
Created June 17, 2019 07:52
subclass pointer convert2 parent class pointer issue
#include<iostream>
class CPartialBase {
public:
CPartialBase() {
std::cout << "CPartialBase this:" << this << std::endl;
}
virtual void funcPart() = 0;
@ppLorins
ppLorins / windows_precision_issue.cc
Created June 12, 2019 16:41
std::chrono::system_clock::now() precision problem under windows .
#include <random>
#include <chrono>
int main(int argc, char** argv){
char sz_time_buf[1024] = { 0 };
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<unsigned long> dis(1,1000);
/*
*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright